********************************************************************************
****** The Effects of WWII on Economic and Health Outcomes across Europe *******
********************************************************************************
* Authors: Iris Kesternich, Bettina Siflinger, James P. Smith, Joachim Winter
* Review of Economics and Statistics, 2014
********************************************************************************
* DOFILE: FIGURE 1, MOVEMENT
********************************************************************************


clear
clear matrix
clear mata
set more off


*** define the path to the directory containing the data files here 
*** or leave "." if the do files are in the current directory 

global datapath "."

*** define the path to the directory to which figures are saved here 
*** or leave "." if they should be saved to the current directory 

global graphpath  "."



insheet using "$datapath\external\txt\population_movement.txt"
sort countryfrom
save "$datapath\external\dta\population_movement.dta", replace


encode countryfrom, g(countryfrom_2)
drop countryfrom
ren countryfrom_2 countryfrom


encode countryto, g(countryto_2)
drop countryto
ren countryto_2 countryto
sort countryfrom yearfrom yearto




* Czechoslovakia
gen     countryto_cz = 1 if countryto == 3
replace countryto_cz = 2 if countryto == 8
replace countryto_cz = 3 if countryto == 9
replace countryto_cz = 4 if countryto == 14

tab amount countryto_cz if countryfrom == 2


* Hungary
gen     countryto_hun = 1 if countryto == 1
replace countryto_hun = 2 if countryto == 5
replace countryto_hun = 3 if countryto == 19

tab amount countryto_hun if countryfrom == 5

	   
* Poland
gen     countryto_pol = 1 if countryto == 11
replace countryto_pol = 2 if countryto == 16
replace countryto_pol = 3 if countryto == 6
replace countryto_pol = 4 if countryto == 18
replace countryto_pol = 5 if countryto == 8

tab amount countryto_pol if countryfrom == 7

	
* Romania
gen     countryto_ro = 1 if countryto == 4
replace countryto_ro = 2 if countryto == 18
replace countryto_ro = 3 if countryto == 1
replace countryto_ro = 4 if countryto == 5

tab amount countryto_ro if countryfrom == 8

	   
* USSR
gen     countryto_ussr = 1 if countryto == 7
replace countryto_ussr = 2 if countryto == 11
replace countryto_ussr = 3 if countryto == 2
replace countryto_ussr = 4 if countryto == 15
replace countryto_ussr = 5 if countryto == 8
replace countryto_ussr = 6 if countryto == 12
replace countryto_ussr = 7 if countryto == 5

tab amount countryto_ussr if countryfrom == 10
  
	   	   
* Yugoslavia
gen     countryto_yug = 1 if countryto == 11
replace countryto_yug = 2 if countryto == 18
replace countryto_yug = 3 if countryto == 1
replace countryto_yug = 4 if countryto == 10
replace countryto_yug = 5 if countryto == 9

tab amount countryto_yug if countryfrom == 11


	   
	   
	   
	   
********************************************************************************
*** Figure 3a: Total inflow of population, 1939-47 
********************************************************************************

sort countryto
by countryto: egen sum_ger_aus    = total(amount) if countryto == 1
by countryto: egen sum_belg       = total(amount) if countryto == 2
by countryto: egen sum_cz         = total(amount) if countryto == 3 | countryto == 5 | countryto == 14
by countryto: egen sum_dk         = total(amount) if countryto == 6
by countryto: egen sum_ger 	   	  = total(amount) if countryto == 8
by countryto: egen sum_it         = total(amount) if countryto == 10
by countryto: egen sum_it_ger_aus = total(amount) if countryto == 11
by countryto: egen sum_pl         = total(amount) if countryto == 12 | countryto == 20
by countryto: egen sum_sw         = total(amount) if countryto == 15
by countryto: egen sum_us_uk_zone = total(amount) if countryto == 17


gen countryto_sc = .
replace countryto_sc = 1  if countryto == 1
replace countryto_sc = 2  if countryto == 2
replace countryto_sc = 3  if countryto == 3 | countryto == 5 | countryto == 14
replace countryto_sc = 4  if countryto == 6
replace countryto_sc = 5  if countryto == 8
replace countryto_sc = 6  if countryto == 10
replace countryto_sc = 7  if countryto == 11
replace countryto_sc = 8  if countryto == 12 | countryto == 20
replace countryto_sc = 9  if countryto == 15
replace countryto_sc = 10 if countryto == 17



twoway (bar sum_ger_aus    countryto_sc, barw(0.8)) ///
	   (bar sum_belg       countryto_sc, barw(0.8)) ///
	   (bar sum_cz 		   countryto_sc, barw(0.8)) ///
	   (bar sum_dk         countryto_sc, barw(0.8)) ///
	   (bar sum_ger        countryto_sc, barw(0.8)) ///
	   (bar sum_it         countryto_sc, barw(0.8)) ///
	   (bar sum_it_ger_aus countryto_sc, barw(0.8)) ///
	   (bar sum_pl         countryto_sc, barw(0.8)) ///
	   (bar sum_sw         countryto_sc, barw(0.8)) ///
	   (bar sum_us_uk_zone countryto_sc, barw(0.8)), ///
	   legend(off) xlabel(1 "AUS/GER" 2 "BEL" 3 "CZE" 4 "DEN" 5 "GER" 6 "ITA" 7 "ITA/AUS/GER" 8 "POL" 9 "SWE" 10 "USA/GBR zone GER" , val angle(45)) xtitle(target countries) ///
       yscale(range(0 10000000)) ylabel( 2000000 "2 Mio" 4000000 "4 Mio" 6000000 "6 Mio" 8000000 "8 Mio" 10000000 "10 Mio", angle(45)) ytitle(# people redistributed by WWII, margin(medium)) ///
	   title(Inflow population 1939-47) xsize(8) ysize(5) 
	   graph export "$graphpath\inflow_total.png", width(600) replace

  
	   
	   
	   
	   
********************************************************************************
*** Figure 3b: Total outflow of population, 1939-47 
********************************************************************************

gen countryfrom_n = .
replace countryfrom_n =  1  if countryfrom == 2
replace countryfrom_n =  2  if countryfrom == 4
replace countryfrom_n =  3  if countryfrom == 5
replace countryfrom_n =  4  if countryfrom == 6
replace countryfrom_n =  5  if countryfrom == 7
replace countryfrom_n =  6  if countryfrom == 8
replace countryfrom_n =  7  if countryfrom == 9
replace countryfrom_n =  8  if countryfrom == 10
replace countryfrom_n =  9  if countryfrom == 11
replace countryfrom_n = 10 if countryfrom == 12
replace countryfrom_n = 11 if countryfrom == 13
replace countryfrom_n = 12 if countryfrom == 14


sort countryfrom_n
by countryfrom_n: egen sum_cz_from 		  = total(amount) if countryfrom_n == 1
by countryfrom_n: egen sum_gr_bul_ru_from = total(amount) if countryfrom_n == 2
by countryfrom_n: egen sum_hun_from       = total(amount) if countryfrom_n == 3 
by countryfrom_n: egen sum_ita_from       = total(amount) if countryfrom_n == 4
by countryfrom_n: egen sum_pl_from        = total(amount) if countryfrom_n == 5
by countryfrom_n: egen sum_ru_from        = total(amount) if countryfrom_n == 6
by countryfrom_n: egen sum_slow_from      = total(amount) if countryfrom_n == 7
by countryfrom_n: egen sum_gdr_from       = total(amount) if countryfrom_n == 8
by countryfrom_n: egen sum_ussr_from      = total(amount) if countryfrom_n == 9
by countryfrom_n: egen sum_yug_from       = total(amount) if countryfrom_n == 10
by countryfrom_n: egen sum_pl_new_from    = total(amount) if countryfrom_n == 11
by countryfrom_n: egen sum_pl_old_from    = total(amount) if countryfrom_n == 12


gen countryfrom_sc = .
replace countryfrom_sc =  1 if countryfrom_n == 1
replace countryfrom_sc =  2 if countryfrom_n == 2
replace countryfrom_sc =  3 if countryfrom_n == 3 
replace countryfrom_sc =  4 if countryfrom_n == 4
replace countryfrom_sc =  5 if countryfrom_n == 5
replace countryfrom_sc =  6 if countryfrom_n == 6
replace countryfrom_sc =  7 if countryfrom_n == 7
replace countryfrom_sc =  8 if countryfrom_n == 8
replace countryfrom_sc =  9 if countryfrom_n == 9
replace countryfrom_sc = 10 if countryfrom_n == 10
replace countryfrom_sc = 11 if countryfrom_n == 11
replace countryfrom_sc = 12 if countryfrom_n == 12
replace countryfrom_sc = 13 if countryfrom_n == 13
replace countryfrom_sc = 14 if countryfrom_n == 14



twoway (bar sum_cz_from         countryfrom_sc, barw(0.8)) ///
	   (bar sum_gr_bul_ru_from  countryfrom_sc, barw(0.8)) ///
	   (bar sum_hun_from        countryfrom_sc, barw(0.8)) ///
	   (bar sum_ita_from        countryfrom_sc, barw(0.8)) ///
	   (bar sum_pl_from         countryfrom_sc, barw(0.8)) ///
	   (bar sum_ru_from         countryfrom_sc, barw(0.8)) ///
	   (bar sum_slow_from       countryfrom_sc, barw(0.8)) ///
	   (bar sum_gdr_from        countryfrom_sc, barw(0.8)) ///
	   (bar sum_ussr_from       countryfrom_sc, barw(0.8)) ///
	   (bar sum_yug_from        countryfrom_sc, barw(0.8)) ///
	   (bar sum_pl_old_from     countryfrom_sc, barw(0.8)) ///
	   (bar sum_pl_new_from     countryfrom_sc, barw(0.8)), ///
	   legend(off) xlabel(1 "Czechoslovakia" 2 "Greece/Bulgaria/Romania" 3 "Hungary" 4 "Italy" 5 "Poland (today's border)" ///
	   6 "Romania" 7 "Slovakia" 8 "GDR" 9 "USSR" 10 "Yugoslavia" 11 "new Poland (former eastern GER)" 12 "old Poland (before WWII)", val angle(45)) xtitle(source countries) ///
       yscale(range(0 10000000)) ylabel( 2000000 "2 Mio" 4000000 "4 Mio" 6000000 "6 Mio" 8000000 "8 Mio" 10000000 "10 Mio", angle(45)) ytitle(# people redistributed by WWII, margin(medium)) ///
	   title(Outflow population 1939-47) xsize(8) ysize(5)
	   graph export "$graphpath\outflow_total.png", width(600) replace



